package org.xx.armory.ofs;

import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;

import static org.apache.commons.lang3.StringUtils.trimToEmpty;
import static org.xx.armory.commons.Validators.greaterThanOrEqual;
import static org.xx.armory.commons.Validators.notBlank;

/**
 * 文件对象的信息。
 */
public final class FileObjectInfo {
    private final String name;
    private final String fullName;
    private final long size;
    private final String description;
    private final Set<FileAttribute> attributes;

    public FileObjectInfo(
            String name,
            String fullName,
            long size,
            String description,
            Collection<FileAttribute> attributes
    ) {
        this.name = notBlank(name, "name");
        this.fullName = notBlank(fullName, "fullName");
        this.size = greaterThanOrEqual(size, "size", 0L);
        this.description = trimToEmpty(description);
        this.attributes = attributes != null ? new HashSet<>(attributes) : Collections.emptySet();
    }

    public String getName() {
        return name;
    }

    public String getFullName() {
        return fullName;
    }

    public long getSize() {
        return size;
    }

    public String getDescription() {
        return description;
    }

    public Set<FileAttribute> getAttributes() {
        return attributes;
    }
}
